package cc.ls51.cms.interceptor;

//import cn.hutool.json.JSONUtil;
//import com.alibaba.druid.support.json.JSONUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestAttributes;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//import java.lang.reflect.Field;
//import java.util.HashMap;
//import java.util.Map;

//定义一个切面
//@Aspect
//@Component
//@Slf4j
//@Order(1)
public class LogRecordAspect {
//    private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.class);

//    // 定义切点Pointcut
//    @Pointcut("execution(* cc.ls51.cms.controller..*.*(..))")
//    public void excudeService() {}
//
//    @Around("excudeService()")
//    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
//        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
//        HttpServletRequest request = sra.getRequest();
//        String url = request.getRequestURL().toString() + request.getPathInfo();
//        String method = request.getMethod();
//        String queryString = request.getQueryString();
//        Object[] args = pjp.getArgs();
//        String params = "";
//        //获取请求参数集合并进行遍历拼接
//        if (args.length > 0) {
//            if ("POST".equals(method)) {
//                params = JSONUtil.toJsonStr(args);
//            } else if ("GET".equals(method)) {
//                params = queryString;
//            }
//        }
//        logger.info("请求开始===地址:" + url);
//        logger.info("请求开始===参数:" + params);
//        // result的值就是被拦截方法的返回值
//        Object result = pjp.proceed();
//        logger.info("请求结束===返回值:" + JSONUtils.toJSONString(result));
//        return result;
//    }
}